package com.huakai.springenv.aspect;

import com.zaxxer.hikari.metrics.IMetricsTracker;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;



/**
 * @author jiaxz
 * @since 2023-05-11
 */
@Aspect
@Component
@Slf4j
public class MyMetricsTracker implements IMetricsTracker {

    private static final long ns = 1000*1000L;
    private static final long AcquireLimit = 50L;
    private static final long UsageLimit = 1000L;

    private static final String DBCon = "DBCon";


    @Override
    public void recordConnectionAcquiredNanos(long elapsedAcquiredNanos) {
        long time = elapsedAcquiredNanos/ns;
        if(time>AcquireLimit){
            log.warn("acquire connection over {} ms",time);
        }
    }

    @Override
    public void recordConnectionUsageMillis(long elapsedBorrowedMillis) {
    }


}
